// Hardware Buffer Array
// (c) jimon game studio

#ifndef JEH_CHARDWAREBUFFERARRAY
#define JEH_CHARDWAREBUFFERARRAY

#include "IHardwareBufferArray.h"
#include "jeStl.h"
#include "jeOpenGLSystemHeader.h"
#include "CRender_OpenGL_Extensions.h"
#include "CShaderMaterial_OpenGL.h"

#ifdef JE_RENDER_OPENGL

namespace je
{
	namespace video
	{
		//! Hardware Buffer Array
		class CHardwareBufferArray_OpenGL:public je::video::IHardwareBufferArray
		{
		protected:
			CRender_OpenGL_Extensions * Extensions;

			LayerInfo Buffers[JE_MAX_SHADER_VERTEX_LAYERS+1];

			s32	VertexObjectCount;
			s32	IndexObjectCount;
			GLenum IndexType;
		public:
			//! Constructor
			CHardwareBufferArray_OpenGL(CRender_OpenGL_Extensions * NewExtensions);

			//! Destructor
			~CHardwareBufferArray_OpenGL();

			//! Attach Hardware Buffer
			void AttachBuffer(IHardwareBuffer * Buffer,HardwareBufferArrayLayers Layer,s32 VariablesPerObject,s32 VariableSize,s32 Stride = 0,s32 Offset = 0,u1 ThisIsIntFormat = false);

			//! Get Layer Info
			LayerInfo & GetLayerInfo(HardwareBufferArrayLayers Layer);

			//! Update layers
			void UpdateLayers();

			//! Bind
			void Bind(CShaderMaterial_OpenGL * ShaderMaterial);

			//! Get vertex count
			inline s32 GetVertexCount()
			{
				return VertexObjectCount;
			}

			//! Get index count
			inline s32 GetIndexCount()
			{
				return IndexObjectCount;
			}

			//! Get Index Type
			inline GLenum GetIndexType()
			{
				return IndexType;
			}

		};
	}
}

#endif

#endif
